package com.nfc.lock.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nfc.lock.dto.response.LockListVO;
import com.nfc.lock.entity.NfcLock;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 锁具Mapper
 */
@Mapper
public interface NfcLockMapper extends BaseMapper<NfcLock> {

    /**
     * 根据NFC ID查询
     */
    NfcLock selectByNfcId(@Param("lockNfcId") String lockNfcId);

    /**
     * 分页查询锁具列表（带配电室和区域信息）
     */
    IPage<LockListVO> selectLockPage(Page<?> page,
                                     @Param("keyword") String keyword,
                                     @Param("roomId") Long roomId,
                                     @Param("regionId") Long regionId,
                                     @Param("lockStatus") Integer lockStatus);

    /**
     * 查询长期未关锁的锁具
     */
    List<NfcLock> selectLongTimeUnlocked(@Param("minutes") Integer minutes);

    /**
     * 检查配电室下是否有锁具
     */
    Long countByRoomId(@Param("roomId") Long roomId);
}
